package com.frxuexi.myvideo.adapter

import android.view.View
import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.frxuexi.lib_base.entity.MyVideoBean
import com.frxuexi.lib_base.entity.MyVideoBeanItem
import com.frxuexi.myvideo.R
import com.frxuexi.myvideo.databinding.ItemMyvideoBinding

class MyVideoAdapter : BaseQuickAdapter<MyVideoBeanItem, BaseViewHolder>(R.layout.item_myvideo) {
    override fun onItemViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        super.onItemViewHolderCreated(viewHolder, viewType)
        DataBindingUtil.bind<ItemMyvideoBinding>(viewHolder.itemView)
    }

    override fun convert(helper: BaseViewHolder, item: MyVideoBeanItem) {
        val binding = DataBindingUtil.getBinding<ItemMyvideoBinding>(helper.itemView)!!
        binding.bean = item

        binding.gsy.apply {
            setUp(item.videopath, false, "")
            titleTextView.visibility = View.GONE
            backButton.visibility = View.GONE
            if (helper.position == 0) {
                startPlayLogic()
            }
        }

        if(item.dianzan==1){
            binding.ivLove.setImageResource(com.frxuexi.lib_base.R.drawable.ic_xihuanred)
        }else{
            binding.ivLove.setImageResource(com.frxuexi.lib_base.R.drawable.ic_xihuan)
        }

        if(item.guanzhu==0){
            binding.ivAdd.setImageResource(com.frxuexi.lib_base.R.drawable.ic_add)
        }else{
            binding.ivAdd.setImageResource(com.frxuexi.lib_base.R.drawable.ic_action_ok)
        }
    }
}